package com.shengde.jinwawaforleader.model.myJob.teachResource;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;

import com.shengde.jinwawaforleader.R;
import com.shengde.jinwawaforleader.model.myJob.adapter.MingshiDetailAdapter;
import com.shengde.jinwawaforleader.network.BaseProtocol;
import com.shengde.jinwawaforleader.network.protocolbean.ProChapterList;

import java.util.List;

/**
 * 教学资源item 详情页面
 */
public class MingshiDetailActivity extends Activity{

	private MingshiDetailAdapter adapter;
	ListView listview;
	public List<ProChapterList.CaselistEntity> list;
	private TextView tv_title;
	public int Id;
	private MingshiDetailActivity activity;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_mingshi_detail);
		activity = MingshiDetailActivity.this;
		Id = getIntent().getIntExtra("id", -1);
		String name = getIntent().getStringExtra("name");
		listview = (ListView)findViewById(R.id.economy_list);
		tv_title = (TextView)findViewById(R.id.tv_title);
		tv_title.setText(name);
		listview.setOnItemClickListener(new OnItemClickListener() {
			
			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				Intent aa = new Intent();
				aa.setClass(MingshiDetailActivity.this, JinriDetailActivity.class);
				aa.putExtra("url",list.get(position).getLink());
				aa.putExtra("keyField",list.get(position).getKeyField());
				aa.putExtra("title",list.get(position).getTitle());
				aa.putExtra("cover",list.get(position).getCover());
				aa.putExtra("id",list.get(position).getId());
				startActivity(aa);
			}
		});

		findViewById(R.id.tv_back).setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
		BaseProtocol.getInstance().getChapterList(activity);
	}
	public void updateData(){
		adapter = new MingshiDetailAdapter(list, this);
		listview.setAdapter(adapter);
	}
}
